﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Defender.Command.AI.AStar
{
    public static class PathFinderHelper
    {
        public const int BLOCKED_TILE = 0;
        public const int EMPTY_TILE = 1;

        public static int RoundToNearestPowerOfTwo(int n)
        {
            if (n <= 0)
            {
                throw new ArgumentOutOfRangeException("Calling this function with a non-positive n doesn't make sense (you sent " + n + ")");
            }
            if ((n == 1) || (n == 2))
            {
                return n;
            }
            return (int)Math.Pow(2.0, Math.Ceiling((double)(Math.Log((double)n) / Math.Log(2.0))));
        }
    }
}